import pygame

class Barrier(pygame.sprite.Sprite):
    def __init__(self, tl, br, groups=[]):
        super().__init__(*groups)
        
        topleft = (tl.x, tl.y)
        bottomright = (br.x, br.y)

        self.width = abs(bottomright[0] - topleft[0])
        self.height = abs(bottomright[1] - topleft[1])
        self.left = min(bottomright[0], topleft[0])
        self.right = max(bottomright[0], topleft[0])
        self.top = min(bottomright[1], topleft[1])
        self.bottom = max(bottomright[1], topleft[1])
        
        self.is_barrier = True
        
        self.surface = pygame.Surface([self.width, self.height])
  
        pygame.draw.rect(self.surface,
                         [255, 0, 0],
                         pygame.Rect(0, 0, self.width, self.height),
                         width=3)
  
        self.rect = self.surface.get_rect(topleft=(self.left, self.top), bottomright=(self.right ,self.bottom))
        self.mask = pygame.mask.from_surface(self.surface)

class BarrierSimple(pygame.sprite.Sprite):
    def __init__(self, l, groups=[]):
        super().__init__(*groups)
        
        self.is_barrier = True
        self.surface = pygame.Surface([l[4], l[5]])
    
        pygame.draw.rect(self.surface,
                    [255, 0, 0],
                    pygame.Rect(0, 0, l[4], l[5]),
                    width=3)
        
        self.rect = self.surface.get_rect(topleft=(l[0], l[1]), bottomright=(l[2], l[3]))
        self.mask = pygame.mask.from_surface(self.surface)